﻿using System;
using System.Collections.Generic;
using System.Windows.Forms;
using ExpertSystem.Interfaces;

namespace ExpertSystem.Views
{
    public partial class ExpertView : Form
    {
        private List<IRule> _rules;

        public ExpertView( List<IRule> rules = null,List<IShip> ships = null,List<IVariable> variables = null)
        {
            InitializeComponent();
            bindingSource1.DataSource = rules;
            bindingSource2.DataSource = ships;
            bindingSource3.DataSource = variables;
        }

        private void dataGridView1_RowsAdded(object sender, DataGridViewRowsAddedEventArgs e)
        {
            DataGridView dataGridView = (DataGridView) sender;
            DataGridViewButtonCell b = (DataGridViewButtonCell) dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[2];
            //b.Value = "Редактировать";
            /*b.Click += delegate {
                                    _rules.Find(
                                        x => x.Name == dataGridView.Rows[dataGridView.Rows.Count - 1].Cells[0].Value).EditRule(); };*/
        }

        private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex == 2)
            {
                var b = (IRule)dataGridView1.Rows[e.RowIndex].DataBoundItem;
                b.EditRule();
            }
        }


    }
}
